<!DOCTYPE html>
<html>
  <head>
    <title>主页</title>
    <link rel="stylesheet" type="text/css" href="/stylesheets/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/stylesheets/blog.css">
  </head>
  <body>
    <header >
        <div class="page-header">
            <% if(!user) { %>
            <div class="user-header">
                <p>
                    <a href="/login">登陆</a>
                    <a href="/register" id="reg">注册</a>
                </p>               
            </div>
            <% } else { %>
            <div class="user-header">
                <p>
                    <a href="#"><%= user.username %></a>
                    <a href="/logout" id="logout">安全退出</a>
                </p>
            </div>
            <% } %>
            <h1><%= title %><small><%= blog.title %></small></h1>
        </div>   	
    </header>
   
    <div id="container" class="container">
        <!-- Display blog content. -->
        <div id="blog-content">
            <div id="blog-info">
                <h3><%= blog.title %></h3>
                <p class="muted"><a href="#"><%= blog.author.username %></a>发布于<%= blog.time.getFullYear() %>/<%= blog.time.getMonth()+1 %>/<%= blog.time.getDate() %></p>               
            </div>
            <div id="content">

                <p class="lead"><%= blog.content %></p>
                <div id="zan"><img name="<%- blog._id %>"  src="/images/1183422.png"></div>
            </div>
        </div>
        <!-- List of comments. -->
        <div id="comment">
            <form class="comment" action="/comment/<%- blog._id %>" method="post">
                <label class="muted">说点什么吧~~</label>
                <textarea class="form-control" rows="3" name="comment"></textarea></br>
                <button id="btncomment" type="submit" class="btn">发布</button>
            </form>
            <% if(comments) {%>
            <div class="list">
                <ul class="unstyled">                   
                    <% for(var i = 0; i < comments.length; i++ ) { %>
                                        
                    <li>
                        <a href="#"><%= comments[i].author.username %>:</a><br>
                        <p><span class="comments"><%= comments[i].content %></span></p>
                        <span class="comment-time">发布于 <%= comments[i].time.getFullYear() %>/<%= comments[i].time.getMonth()+1 %>/<%= comments[i].time.getDate() %></span><a id="commendzan" name="<%- comments[i]._id %>">赞</a><span id="times"><%= comments[i].recommend %></span>    
                    </li>  
                    <% } %>                                   
                </ul>               
            </div>
            <% } %>
        </div>
    </div>
    <footer>
        <p><small>&copy;Copyring All About Gaudi</small></p>
    </footer> 
        <script src="/javascripts/jquery.min.js" type="text/javascript"></script>
        <script src="/javascripts/blog.js" ></script>        
    </body>
</html>
